var app = getApp(),
  $ = require("../../utils/httpHelper.js"),
  WxNotificationCenter = require("../../WxNotificationCenter/WxNotificationCenter.js")//通知传参

var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');


Page({
  data: {
    objarr: [],
    shoplist:[],
    position:[],
    shopname:'高新二路店',
    width:0,
    titleimgH:0,
    titleimgW:0,
    spHeigth:0,
    aboutHeight:0,
    indexdata:{}
  },
  onShareAppMessage: function (res) {
    let member_id = app.globalData.userInfo.member_id
    return {
      title: '牛邵教育',
      path: '/pages/index/index?inviter_id=' + member_id,
      success: function (res) {
        // 转发成功
      },
      fail: function (res) {
        // 转发失败
      }
    }
  },
  onLoad: function (options) {
    var that = this;
    console.log(wx.getStorageSync('rd_session'))
    
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        that.setData({ width: res.windowWidth-20 })
      }
    })

    $.httpPost("index", {}, (data, err) => {
      this.setData({
        indexdata: data.data,
        shopname: wx.getStorageSync('shop_name')
      })
    })
    
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  togoodsdetail(e) {
    let id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/goods/goods_detail?id=' + id + '&status=' + 'good',
    })
  },
  toKecheng(){
    wx.switchTab({
      url: '/pages/kecheng/kecheng'
    })
  },
  tozixun(){
    wx.navigateTo({
      url: '/pages/zixun/zxlist',
    })
  },
  toAbout(e) {
    // 只允许从相机扫码
    // wx.scanCode({
    //   onlyFromCamera: true,
    //   success: (res) => {
    //     console.log(res)
    //   }
    // })
    wx.navigateTo({
      url: '/pages/about/about',
    })
  },
  toyhq(){
    wx.navigateTo({
      url: '/pages/yhq/getyhq',
    })
  },
  shangc(e) {
    let id = e.currentTarget.dataset.id
    app.globalData.shangc_id = id
    wx.switchTab({
      url: '/pages/shangc/shangc',
    }) 
  },
  tovedio(){
    wx.navigateTo({
      url: '/pages/vedio/vediolist',
    })
  },
  tozs(){
    wx.navigateTo({
      url: '/pages/yeni/zhaoshang',
    })
  },
  topl(){
    wx.navigateTo({
      url: '/pages/pl/pl',
    })
  },
  togoodsinfo(e){
    let id = e.currentTarget.dataset.id
    let status = e.currentTarget.dataset.status
    wx.navigateTo({
      url: '/pages/goods/goods_detail_buy?id=' + id + '&status=' + status,
    })
  },
  chooseshop(){
    wx.navigateTo({
      url: '/pages/index/shops?shopname='+this.data.shopname,
    })
  },
  titleload(e){
    this.setData({
      titleimgW: 100,
      titleimgH: app.fixImgW(e, 100),
    })
  },
  todetail(e) {
    let id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/zixun/zxdetail?id=' + id,
    })
  },
  spImgload(e) {
    let that = this
    this.setData({
      spHeigth: app.fixImgW(e, that.data.width),
    })
  },
  aboutImgload(e) {
    let that = this
    this.setData({
      aboutHeigth: app.fixImgW(e, that.data.width),
    })
  },
  imageLoad: function (e) {
    var _this = this;
    var $width = e.detail.width,    //获取图片真实宽度  
      $height = e.detail.height,
      ratio = $width / $height;   //图片的真实宽高比例  
    var viewWidth = this.data.width+20,           //设置图片显示宽度，  
      viewHeight = this.data.width / ratio;    //计算的高度值     
    this.setData({
      imgwidth: viewWidth,
      imgheight: viewHeight
    })
  },
  imageLoada: function (e) {
    var _this = this;
    var $width = e.detail.width,    //获取图片真实宽度  
      $height = e.detail.height,
      ratio = $width / $height;   //图片的真实宽高比例  
    var viewWidth = this.data.width,           //设置图片显示宽度，  
      viewHeight = this.data.width / ratio;    //计算的高度值     
    this.setData({
      imgwidtha: viewWidth,
      imgheighta: viewHeight
    })
  } 
  
});